package org.smarthings.scripting;

import java.util.List;

import javax.script.Bindings;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineFactory;
import javax.script.ScriptEngineManager;

public class ScriptEngineManagerProxy extends ScriptEngineManager {

	private ScriptEngineManagerDelegate delegatee;

	public ScriptEngineManagerProxy() {
		setDelegate(null);
	}

	public void setDelegate(ScriptEngineManagerDelegate delegatee) {
		this.delegatee = (delegatee == null) ? new ScriptEngineManagerDelegate() : delegatee;
	}

	public Object get(String key) {
		return delegatee.get(key);
	}

	public ScriptEngine getEngineByExtension(String extension) {
		return delegatee.getEngineByExtension(extension);
	}

	public ScriptEngine getEngineByMimeType(String mimeType) {
		return delegatee.getEngineByMimeType(mimeType);
	}

	public ScriptEngine getEngineByName(String shortName) {
		return delegatee.getEngineByName(shortName);
	}

	public List<ScriptEngineFactory> getEngineFactories() {
		return delegatee.getEngineFactories();
	}

	public void put(String key, Object value) {
		delegatee.put(key, value);
	}

	public void registerEngineExtension(String extension, ScriptEngineFactory factory) {
		delegatee.registerEngineExtension(extension, factory);
	}

	public void registerEngineMimeType(String type, ScriptEngineFactory factory) {
		delegatee.registerEngineMimeType(type, factory);
	}

	public void registerEngineName(String name, ScriptEngineFactory factory) {
		delegatee.registerEngineName(name, factory);
	}

	public void registerScriptEngineFactory(ScriptEngineFactory factory) {
		delegatee.registerScriptEngineFactory(factory);
	}

	// Livetribe JSR-223 2.0.6 API
	public Bindings getGlobalScope() {
		return getBindings();
	}

	// Livetribe JSR-223 2.0.6 API
	public void setGlobalScope(Bindings globalScope) {
		setBindings(globalScope);
	}

	public Bindings getBindings() {
		return delegatee.getBindings();
	}

	public void setBindings(Bindings bindings) {
		delegatee.setBindings(bindings);
	}

}
